var router = require("express").Router();

var Student = require("../modules/db/student");

router.get('/search',(req,res)=>{
    console.log(req.query);
    let condation = {};//查询条件，默认为空，为搜索准备的条件

    if (req.query.username) {
        condation.username = new RegExp(req.query.username, 'gi');
    }
    if (req.query.age) {
        condation.age = req.query.age;
    }
    if (req.query.phone) {
        condation.phone = new RegExp(req.query.phone);
    }
    Student
        .find(condation)
        .exec((err, data)=>{
            res.json({
                error: 0,
                data: data,
                // keyword: req.query.sear,
              });
        });
 
})


module.exports = router;